package com.xca.is.repository;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.xca.is.service.TongYiService;
import com.xca.is.utils.LenientGsonConverterFactory;

import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
import io.reactivex.rxjava3.core.Observable;
import io.reactivex.rxjava3.schedulers.Schedulers;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava3.RxJava3CallAdapterFactory;

public class TongYiRepository {
    private static final String URL = "https://api.mhimg.cn/api/";
    private TongYiService service ;

    public TongYiRepository(){
        Gson gson = new GsonBuilder().setLenient().create();
        Retrofit retrofit = new Retrofit.Builder()
                .baseUrl(URL)
                .addCallAdapterFactory(RxJava3CallAdapterFactory.create())
                .addConverterFactory(LenientGsonConverterFactory.create(gson))
                .build();
        service = retrofit.create(TongYiService.class);
    }



    public Observable<String> getData(String text){
        return service.getData(text)
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeOn(Schedulers.io());
    }
    public Observable<String> getData2(String text){
        return service.getData2(text)
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeOn(Schedulers.io());
    }
    public Observable<String> getData3(String text){
        return service.getData3(text)
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeOn(Schedulers.io());
    }
    public Observable<String> getData4(String text){
        return service.getData4(text)
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeOn(Schedulers.io());
    }
    public Observable<String> getData5(String text){
        return service.getData5(text)
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeOn(Schedulers.io());
    }
    public Observable<String> getData6(String text){
        return service.getData6(text)
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeOn(Schedulers.io());
    }
    public Observable<String> getData7(String coder ,String text){
        return service.getData7(coder,text)
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeOn(Schedulers.io());
    }
    public Observable<String> getData8(String text){
        return service.getData8(text)
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeOn(Schedulers.io());
    }
}

